package com.zzyl.nursing.controller.member;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.domain.PageResult;
import com.zzyl.nursing.dto.memberDto.MemberNursingProjectDto;
import com.zzyl.nursing.service.member.IMemberNursingProjectService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/member/orders/project")
public class MemberNursingProjectController {

    private final IMemberNursingProjectService projectService;

    @GetMapping("/page")
    public TableDataInfo<NursingProject> page(MemberNursingProjectDto projectDto) {
        // 调用分页查询
        IPage<NursingProject> page = projectService.page(projectDto);

        // 将分页结果封装进 TableDataInfo
        TableDataInfo<NursingProject> tableDataInfo = new TableDataInfo<>();
        tableDataInfo.setTotal(page.getTotal());   // 总记录数
        tableDataInfo.setRows(page.getRecords());  // 当前页数据
        tableDataInfo.setCode(200);                // 状态码
        tableDataInfo.setMsg("查询成功");          // 消息内容

        return tableDataInfo;
    }

    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return AjaxResult.success(projectService.getById(id));
    }



}